#pragma once
#include <shared_mutex>
#include <mutex>
#include <chrono>
#include "arrow/arrow.h"
#include "i_session.h"
#include "../common/common.h"

namespace ArrowWebCodeView
{

class CSessionManager 
{
    using SetStr = std::set<std::string>;

public:
    CSessionManager();

    virtual ~CSessionManager();

    void Init(asio::io_context& ioContext);
    void Run();
    void Deini();

    /// @brief 
    /// @param pSession 
    void AddSession(SharedPtrISession pSession);

    void RemoveSession(SharedPtrISession pSession);

    int32_t Count();

private:
    std::set<SharedPtrISession> m_setSessions;

    std::chrono::steady_clock::time_point m_LastDelAllMsgSrcInfo;
    SetStr m_setMsgSrcInfo;
};

using AppSessionManger = Arrow::Pattern::Singleton<CSessionManager>;
}